<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2023/11/3
  Time: 15:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>JSONP跨域</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.min.js"></script>
    <script>
        $(function () {
            $("#btn").click(function () {
                $.ajax({
                    type: "post",
                    url: "http://127.0.0.1:8080/ajax/jp",
                    // jsonp配置用于控制请求中参数的key,其默认值为callback
                    // 开发中不建议使用该配置,如果一旦进行修改,后台开发人员也要随之修改,比较麻烦
                    // jsonp:"aa",
                    dataType: "jsonp",
                    success: function (result) {
                        console.log(result);
                    }
                });
            });
        });
    </script>
</head>
<body>
<button id="btn">JSONP跨域</button>
</body>
</html>
